

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="layout" content="main" />
        <gui:resources components="toolTip"/>
        <title>Historia konta</title>
    </head>
    <body>
        <div class="nav">
            <g:ifAllGranted role="ROLE_ADMIN">
                <span class="menuButton"><g:link class="list" controller="user" action="list">Użytkownicy</g:link></span>
                <span class="menuButton"><g:link class="create" controller="commitment" action="create" id="${person.id}">Dodaj operację</g:link></span>
            </g:ifAllGranted>
        </div>

        <div class="body">
			<h1>Historia konta ${person}</h1>
			<g:if test="${flash.message}">
			<div class="message">${flash.message}</div>
			</g:if>
            <h3>Stan konta: ${person.balance}</h3>
			<div class="list">

                <table>
                <thead>
                    <tr>
                        <g:sortableColumn property="dateCreated" title="Data" />
                        <g:sortableColumn property="commitmentType" title="Operacja" />
                        <g:sortableColumn property="value" title="Wartość" />
                        <g:sortableColumn property="balance" title="Saldo po operacji" />
                        <g:ifAllGranted role="ROLE_ADMIN">
                            <th>&nbsp;</th>
                        </g:ifAllGranted>
                    </tr>
                </thead>
                <tbody><%----%>
                <g:each in="${commitments}" status="i" var="commitment">
                    <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        <td><jep:date date="${commitment?.dateCreated}" /></td>
                        <td>
                            <gui:dialog
                                id="dialog${commitment.id}"
                                title="${commitment.commitmentType.name}"
                                triggers='[show:[type:"link", text:"${commitment.commitmentType.name}", on:"click"]]'
                            >
                                <g:render template="show" bean="${commitment}" var="commitment" />
                            </gui:dialog>
                        </td>
                        <td>${commitment.value}</td>
                        <td>${commitment.balance}</td>
                        <g:ifAllGranted role="ROLE_ADMIN">
                            <td class="actionButtons">
                                <span class="actionButton">
                                    <g:link action="edit" id="${commitment.id}">Edycja</g:link>
                                </span>
                            </td>
                        </g:ifAllGranted>
                    </tr>
                </g:each>
                </tbody>
                </table>
			</div>

            <div class="paginateButtons">
				<g:paginate
                total="${person?.commitments?.size()}"
                id="${person.id}"
                next="Następne"
                prev="Poprzednie" />
			</div>

        </div>
    </body>
</html>
